package code.zzl.monitor.admin.config.message;

import code.zzl.monitor.admin.tirgger.listener.MonitorLogListener;
import code.zzl.monitor.constant.RedissonConstant;
import org.redisson.api.RTopic;
import org.redisson.api.RedissonClient;
import org.springframework.context.annotation.Bean;
import code.zzl.monitor.sdk.model.LogMessage;
import org.springframework.stereotype.Component;

/**
 * @ Author 龙
 * @ Date 2024-08-03 18:07
 * @ Description: TODO
 */
@Component
public class RedisMonitorTopic {
    @Bean
    public RTopic monitorTopicRedis(RedissonClient redissonClient, MonitorLogListener monitorLogListener) {
        RTopic topic = redissonClient.getTopic(RedissonConstant.TOPIC_SDK_KEY);
        topic.addListener(LogMessage.class, monitorLogListener);
        return topic;
    }
}
